In this section, we'll learn how to use ANGULAR2 to show the data, and how to use its built-in directives NgFor andNgIf
First make sure you have a ANGULAR2 sample program that you can run, preferably the QuickStart small project that we completed in the previous chapter, or the QuickStart project that you completed on the website above, because our explanation is on that basis; Then let's start the happy j
Angular 4.x NgIf usage, angularngif
NgIf instructions
The ngIf command is used to render then or else template content at a specified position based on the expression value.
The then template is an inline template associated with the ngIf command by default unless it is bound to different values.
The else template
In the combination of these NG instructions written in an article, there is basically a rule, the Beast will function similar to the same kind of most of the group together to facilitate understanding and memory.This three instructions are also the operation of the DOM elements, the page display/hide the judgment, add/Remove the judgment.NgifThe ngif instruction adds to/removes the DOM tree from the Boolean value returned by the specified expression.f
, we need to clear the current data, reset the status of the form, and wait for the user to re-enter. If we only clear the data, the verification errors will be detected. We need to reset the form controls to the unmodified status. This is quite simple in Angular2. It provides a reset method.
Add a reset button in it:
Then in the component:
reset(theForm: NgForm) { theForm.reset(); return false;}
Note that we need to make this method return false s
Typically, the web developer chooses to set the element style attribute display to none to hide the target element. In this way, although these elements are not visible but remain in the DOM, the benefit is that if the element needs to be displayed again soon, the component does not need to be reinitialized, and the component's state can be displayed immediately because it was previously reserved. But hiding elements also poses other problems, in the angular application, if you hide an element t
"Preface"
This is also from the document written by Xiaofeng, I do end-to-end testing when the project is used. "Body"
Project Flow install webstorm-Continuous Integration Server
Download Address: http://www.jetbrains.com.cn/webstorm.html
New ANGULAR2 Project
Enter directly from the command prompt:
ng New Angular-cli-project
PS:ANGULAR2 basic files have been created, the next is to download the project depends on the Nodejs package, with Ng ne
Because a project needs to convert a set of continuous photos into animated forms for transmission, we have studied this aspect, later, we found a project named NGif In the open-source project. Through the methods provided in this project, we can directly implement this requirement. However, I found that this project is not directly written in C #. On the contrary, it calls a Java class and converts it to C # code, this is certainly not within the sco
Angular2 entry-Architecture Overview, angular2 Architecture OverviewToo many rows too many rowsIntroduction
In March 23, Angular4 was officially released (not 3 ). It seems that Angular2 is now learning again later-_-|. Angular2 has made great changes based on Angular1. I asked an
Implementation of Angular2 form custom validators, angular2 form
This article describes how to determine the result of the validators. Here, we will look at how to implement a custom validators.
Target
We need to implement a mobile phone number verification tool. The instance used is based on the instance in the previous article, that is, the form page of user information input. We add a cell phone number v
Example code of the angular2 series route transition animation and angular2 example code
Angular2's animation system gives you the ability to make a variety of animation effects, and strives to build an animation with the same performance as the native CSS animation.
Angular2 animation is mainly combined with @ Compone
Angular2 entry-Data Binding and angular2 entry-level bindingToo many rows too many rowsIntroduction
In Angular2, the data binding method is one-way by default. The data binding method can be divided:
1. Property binding and interpolation expression component class-> Template
2. Event binding: Template-> component class
3. Bidirectional binding: Template
Zookeepe
Angular2 getting started, angular2 getting started
Recently, versions of angular2, 1, and 2 have changed significantly. The following summarizes some learning websites and installation steps.
Official Chinese website (required ):
Https://angular.cn
Lazy learning:
Http://www.imooc.com/learn/789
Support for bootstrap UI Components
Https://github.com/angular-ui/boo
Angular2 countdown component usage details, angular2 Usage Details
The project encounters a countdown requirement. Considering that it will be used in other modules in the future, it encapsulates a component by itself. It is easy to reuse later.
The component requirements are as follows:-Receiving the delivery deadline of the parent component-Receive parent-level component delivery title
Component Effect
V
here, Angular2 is packaged in production mode with Webpack2:Use rollup packaging or comparison pit, function and plug-in is not as webpack, the key does not support code separation, resulting in angular lazy loader will not be able to use. Specific steps:Angular=>aot=>webpack (Tree shaking Uglify)angular=>aot:First you need to rely on:"@angular/compiler" "@angular/compiler-cli" "@angular/platform-browser".NPM Install Them.Here is the directory structu
Angular2 searches for and resets the button for a live animation, and angular2 for a live Animation
Requirement: Add a search and reset transfer animation to the Project Management page.
The first thought was to use angular2's animations attribute.
// project.component.tsimport {trigger, state, style, animate, transition} from '@angular/animations';@Component({ s
How to use pipeline Pipe of Angular2, and pipeline pipe of angular2
Pipeline Pipe can use data as input and convert and output data according to rules. There are many built-in Pipe in Angular2, such as DatePipe, UpperCasePipe, and currenpolicipe. Here we will mainly introduce how to customize Pipe.
1. MPS queue Definition
The following code defines Pipe:
import {
Angular2 custom paging component, angular2 custom Paging
In the project, parameters sent from the frontend to the backend are as follows:
PageSize: number of entries per page
PageNo: Current page number
For example, if there are currently 1st pages and 20 records on each page, the background returns 20 records on 1st pages (SQL should use limit to retrieve paging data)
At the same time, the back-end interfa
Detailed explanation of Http request principles and usage in angular2 and angular2
This document describes the principles and usage of Http requests in angular2. We will share this with you for your reference. The details are as follows:
Provide HTTP Services
HttpModule is not the core module of Angular. Angular is an optional method for Web access.@angular/http.
'). Touched">{{signupform.get (' confirm '). Errors?. Confirmpassword.message}}span>
span*ngif= "signupform.get (' confirm '). Haserror (' required ') signupform.get (' Confirm '). Dirty">This field is requredspan>
Div>
Switch-control formcontrolname= "Newsletter"> Switch-control>
Div>
form> Here with the code we set the default value to being true thought "WriteValue" method handle by Angul
)= "Callphone (phone.value)">PagerButton> Fax refers to the input element; pass it ' value ' to an event handler - inputVar-fax Placeholder= "Fax Number"> Button(click)= "Callfax (fax.value)">FaxButton>Everything is in silence!*Grammar and template tagsFirst look at the application of syntax and template tags:*ngif= "isActive"> I am a paragraph p>Equivalent[ngif]= "isActive">p> I am a paragraph P
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.